Repository navigation
Generator: share repeated code, no change to the generated text - #303
Merged
Merged
Conversation
A refactor of the source generator's own code. The text it emits is byte-identical to before: the generated file of the generator tests (counters on and off) and of the generated benchmarks, compared with a recursive diff before and after, is empty. What changed: - The first line of a partial model's Bind is appended as a line of its own, not through a placeholder that only lined up with the tabs after it. - A member's read statement takes its ordinal as a parameter. The two-step replacement of a second placeholder is gone. - The fully qualified symbol display format is declared once, on ModelReader. - One helper says whether a type is Nullable<T> and one returns its underlying type; the three places that spelled it out use them. - One helper tells whether a member or parameter carries a null policy or null value attribute. - One iterator walks a type and its base types; the four loops that did it by hand use it. - EquatableArray drops its length, indexer and enumerator, which nothing used. Items, Equals and GetHashCode, which the incremental cache relies on, are unchanged. Looked at and left alone: - The two query-receiver tests in the interceptor are not repeated (each appears once, with different sets), so a helper would only add lines. - The public-setter pattern appears twice as a one-clause test and a third time inside a pattern a helper cannot replace; the helper would be longer than the code it replaces. - The empty strings Site carries for a typed query are documented where they are made and sit in the cached model; changing them gains nothing. Checks: whole solution Release build without warnings; generator tests and core tests in Release; dotnet format style and analyzers on the generator and its tests. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A refactor of the source generator's own code. The text it emits is byte-identical to before. No public API changes and nothing at run time: the generator runs at build time, and the code it generates is the same.
What changed
Bindis appended as a line of its own, not through a placeholder that only lined up with the tabs after it.ModelReader.Nullable<T>and one returns its underlying type; the three places that spelled it out use them.EquatableArraydrops its length, indexer and enumerator, which nothing used.Items,EqualsandGetHashCode, which the incremental cache relies on, are unchanged.Looked at and left alone
nullwould gain nothing.The net is +1 line (49 added, 48 removed): this removes repeated spellings, not code.
Checks
dotnet formatstyle and analyzers clean on all 28 checks, DocFX 0 warnings, the style scan clean.🤖 Generated with Claude Code